package com.meishij.adapter;

import android.content.Context;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.meishij.R;
import com.meishij.entry.ShiHua_Datail_Entry;

import java.util.List;

/**
 * Created by Administrator on 2016/10/13.
 * 我是youngKaka 我的心愿是世界和平
 */

public class ShiHua_Detail_Comment_Adapter extends RecyclerView.Adapter<ShiHua_Detail_Comment_Adapter.ViewHolder> {

    private Context context;
    private List<ShiHua_Datail_Entry.CommentListBean> list;

    public ShiHua_Detail_Comment_Adapter(Context context, List<ShiHua_Datail_Entry.CommentListBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_shihua_detail_comment_child, null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.username.setText(list.get(position).getUser_info().getUser_name());
        holder.time.setText(list.get(position).getCreate_time());
        holder.content.setText(list.get(position).getContent());
        holder.zan.setText(list.get(position).getDing_num());
        Uri uri = Uri.parse(list.get(position).getUser_info().getAvatar());
        holder.simpleDraweeView.setImageURI(uri);
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {

        SimpleDraweeView simpleDraweeView;
        TextView username;
        TextView time;
        TextView zan;
        TextView content;

        public ViewHolder(View itemView) {
            super(itemView);
            simpleDraweeView = ((SimpleDraweeView) itemView.findViewById(R.id.sdv_shihua_detail_comment_user_logo));
            username = ((TextView) itemView.findViewById(R.id.tv_shihua_detail_comment_username));
            time = ((TextView) itemView.findViewById(R.id.tv_shihua_detail_comment_time));
            zan = ((TextView) itemView.findViewById(R.id.tv_shihua_detail_comment_zan));
            content = ((TextView) itemView.findViewById(R.id.tv_shihua_detail_comment_content));
        }
    }

}
